package GUI;

import java.util.ArrayList;

import javax.swing.table.AbstractTableModel;

import Control.Ctr;
import Model.Court;

public class CourtTable extends AbstractTableModel {

private static final String[] columnNames = { "ID" , "Court Name"};
private Ctr ctr;

private ArrayList<Court> Court;
public CourtTable(){
	Court = new ArrayList<Court>();
	ctr = new Control.Ctr();

	for(Court e : ctr.findAllCourt() )
	{Court.add(e);
	}
}
public CourtTable(Court c)
{	ctr = new Control.Ctr();
	Court = new ArrayList<Court>();
	Court.add(c);}

@Override
public int getColumnCount() {
    // 
    return columnNames.length;
}

@Override
public int getRowCount() {
    return Court.size();
}

@Override
public String getColumnName(int column) {
    return columnNames[column];
}

@Override
public Object getValueAt(int rowIndex, int columnIndex) {
     {
    	switch (columnIndex){
   case 0:
        return Court.get(rowIndex).getCoID();
    case 1:
    	return Court.get(rowIndex).getCo_name();
    
    			}
    }
    
    return null;
}   
}
